<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>供货商信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" type="text/css" href="../common/layui/css/layui.css" media="all">
	<link rel="stylesheet" type="text/css" href="../common/bootstrap/css/bootstrap.css" media="all">
	<link rel="stylesheet" type="text/css" href="../common/global.css" media="all">
	<link rel="stylesheet" type="text/css" href="../css/personal.css" media="all">
</head>

<style>
	#img{
		position: absolute;
		left: 0;
		top: 0;
		opacity: 0;
	}
</style>
<body>
<!--此页面未供货商信息修改页面-->
<section class="layui-larry-box">
	<div class="larry-personal">
		<header class="larry-personal-tit">
			<span>药品信息</span>
		</header><!-- /header -->
		<div class="larry-personal-body clearfix">
			<form class="layui-form col-lg-5" action="" method="post" id="drug_info">


				<div class="layui-form-item">
					<label class="layui-form-label">药品名称</label>
					<div class="layui-input-block">
						<input type="text" id="dr_name" name="name"  autocomplete="off" class="layui-input" value="">
						<input type="text" id="drug_id" name="id"  autocomplete="off" class="layui-input" value="" hidden="hidden">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">有效期</label>
					<div class="layui-input-block">
						<input type="text" id="dr_validity" name="validity"  autocomplete="off" class="layui-input" value="">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">剂型</label>
					<div class="layui-input-inline">
						<select name="dosageform" class="newsLook" lay-filter="browseLook" id="dr_dosageform">
							<option value="颗粒" >颗粒</option>
							<option value="片剂" >片剂</option>
							<option value="溶液" >溶液</option>
							<option value="气体" >气体</option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">所属公司</label>
					<div class="layui-input-block">
						<input type="text" id="dr_storename" name="storename"  autocomplete="off" class="layui-input" placeholder="">
						<!--添加员工默认在职-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">药品价格</label>
					<div class="layui-input-block">
						<input type="text" id="dr_price" name="price"  autocomplete="off" class="layui-input" placeholder="">
						<!--添加员工默认在职-->
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">药品销量</label>
					<div class="layui-input-block">
						<input type="text" id="dr_sales" name="sales"  autocomplete="off" class="layui-input" placeholder="">
					</div>
				</div>


				<div class="layui-form-item" hidden="hidden">
					<label class="layui-form-label"></label>
					<div class="layui-input-block">
						<label for="img">
							<input type="button" id="btn" value="请上传识别图像" class="layui-btn layui-btn-normal" hidden="hidden"><span name="picture" id="text"></span>
							<input type="file" name="img" id="img"><br /><br />
						</label>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">类型</label>
					<div class="layui-input-inline">
						<select name="drugtypeid" class="newsLook" lay-filter="browseLook" id="drug_type">
							<option value="1" >补益类用药</option>
							<option value="2" >维生素钙</option>
							<option value="3" >消化系统</option>
							<option value="4" >感冒用药</option>
							<option value="5" >儿科用药</option>
							<option value="6" >皮肤用药</option>
							<option value="7" >五官用药</option>
							<option value="8" >呼吸系统</option>
							<option value="9" >妇科用药</option>
							<option value="10" >男科用药</option>
							<option value="11" >止痛镇痛</option>
							<option value="12" >风湿骨外伤用药</option>
						</select>
					</div>
				</div>



				<div class="layui-form-item">
					<div class="layui-input-block">
						<button class="layui-btn" type="button" onclick="adddurg()" lay-filter="demo1">立即修改</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</div>


</section>
<script type="text/javascript" src="../common/layui/lay/dest/layui.all.js"></script>
<script src="../jsplug/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="../jsplug/jparticle.jquery.js"></script>
<script type="text/javascript" src="../common/layui/layui.js"></script>
<script src="../js/token.js"></script>
<script type="text/javascript">
	/**
	 * 修改员工信息(根据id)
	 * 先获取从url传来的参数
	 */
	$(function (){
		var id = location.search.split("=")[1];
		document.getElementById("drug_id").value=id;
		$.post("/drug/toupdata",{id:id},function (res){
			$("#dr_name").val(res.data.name)
			$("#dr_validity").val(res.data.validity)
			//$("#dr_dosageform").val(res.data.dosageform)
			$("#dr_storename").val(res.data.storename)
			$("#dr_price").val(res.data.price)
			$("#dr_sales").val(res.data.sales)
			//$("#drug_type").val(res.data.drugtypeid)

		/*剂型*/
			if (res.data.dosageform=="颗粒"){
				document.getElementById("dr_dosageform").options[0].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.dosageform=="片剂"){
				document.getElementById("dr_dosageform").options[1].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.dosageform=="溶液"){
				document.getElementById("dr_dosageform").options[2].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else {
				document.getElementById("dr_dosageform").options[3].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}


			/*类型*/
			if (res.data.type==="补益类用药"){
				document.getElementById("drug_type").options[0].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type==="维生素钙"){
				document.getElementById("drug_type").options[1].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type==="消化系统"){
				document.getElementById("drug_type").options[2].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}
			else if (res.data.type=="感冒用药"){
				document.getElementById("drug_type").options[3].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type=="儿科用药"){
				document.getElementById("drug_type").options[4].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type=="皮肤用药"){
				document.getElementById("drug_type").options[5].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type=="五官用药"){
				document.getElementById("drug_type").options[6].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type=="呼吸系统"){
				document.getElementById("drug_type").options[7].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type=="妇科用药"){
				document.getElementById("drug_type").options[8].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type=="男科用药"){
				document.getElementById("drug_type").options[9].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}else if (res.data.type=="止咳阵痛"){
				document.getElementById("drug_type").options[10].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			} else {
				document.getElementById("drug_type").options[11].selected = true;
				layui.use(['form','upload'],function() {
					var form = layui.form();
					form.render();
				})
			}

		},"json")
	})





	/*修改员工操作*/
	function adddurg(){
		$.post("/drug/savedrug",$("#drug_info").serialize(),function(res){
			layer.confirm('供货商修改成功，前往查看！', {
			icon: 1,        //会出现正确的图片
			btn: ['好']     //按钮
		}, function(){
			window.location.href="drug_table.html";//点击“好”后进行跳转
		});

		},"json")
}





	layui.use(['form','upload'],function(){
		var form = layui.form();
		form.render();
		layui.upload({
			url: '' ,//上传接口
			success: function(res){
				//上传成功后的回调
				console.log(res)
			}
		});

	});

</script>
</body>
</html>